package com.emily.test.service.impl;

import com.emily.test.mapper.TMenuMapper;
import com.emily.test.model.TMenu;
import com.emily.test.service.TMenuService;
import com.emily.test.utils.ConstentUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("menuServiceAgent")
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class)
public class TMenuServiceImpl implements TMenuService {

    @Resource
    private TMenuMapper tMenuMapper;

    @Override
    public List<TMenu> getMenuInfoListByCondition(TMenu tMenu) {
        if(!ConstentUtil.isEmpty(tMenu.getState())){
            return tMenuMapper.getMenuInfoListByConditionWithInDel(tMenu);
        }
        return tMenuMapper.getMenuInfoListByConditionWithOutDel(tMenu);
    }

    @Override
    public int insertMenuInfo(TMenu tMenu) {
        return tMenuMapper.insertSelective(tMenu);
    }

    @Override
    public int modifyMenuInfoById(TMenu tMenu) {
        return tMenuMapper.modifyMenuInfoById(tMenu);
    }

    @Override
    public int updateMenuInfoByCondition(List<TMenu> tMenuList) {
        return tMenuMapper.updateMenuInfoByCondition(tMenuList);
    }
}
